package com.zis.auction.model;

import com.zis.auction.model.base.AuctBidModel;
import com.zis.utils.DateUtil;
import org.beetl.sql.core.annotatoin.InsertIgnore;
import org.beetl.sql.core.annotatoin.Table;
import org.beetl.sql.core.annotatoin.UpdateIgnore;
import org.springframework.data.annotation.Transient;

import java.io.Serializable;

/**
 * Create by wangshen 2017/12/28
 */
@Table(name = "a_auct_bid")
public class AuctBid extends AuctBidModel implements Serializable {

    private String bidAddr;

    private String areaAddr;

    @Transient
    private String[] bidOptions;

    @Transient
    private String[] areaOptions;

    @InsertIgnore
    @UpdateIgnore
    public String getBidAddr() {
        if (bidAddr == null) {
            return "";
        }
        return bidAddr.replaceAll(",","-");
    }

    public void setBidAddr(String bidAddr) {
        this.bidAddr = bidAddr;
    }

    @InsertIgnore
    @UpdateIgnore
    public String getAreaAddr() {
        if (areaAddr == null) {
            return "";
        }
        return areaAddr.replaceAll(",","-");
    }

    public void setAreaAddr(String areaAddr) {
        this.areaAddr = areaAddr;
    }

    @InsertIgnore
    @UpdateIgnore
    public String[] getBidOptions() {
        return bidOptions;
    }

    public void setBidOptions(String[] bidOptions) {
        this.bidOptions = bidOptions;
    }

    @InsertIgnore
    @UpdateIgnore
    public String[] getAreaOptions() {
        return areaOptions;
    }

    public void setAreaOptions(String[] areaOptions) {
        this.areaOptions = areaOptions;
    }

    public String getFormatStartTime(){
        if(getStartTime()!=null){
            return DateUtil.getDate(getStartTime(),"yyyy-MM-dd HH:mm");
        }
        return null;
    }

    public String getFormatBidDate(){
        if(getBidDate()!=null){
            return DateUtil.getDate(getBidDate(),"yyyy-MM-dd");
        }
        return null;
    }

}
